#include "extract.h"
#include<QPainter>
#include"mypushbutton.h"
#include"widget.h"
#include<QTimer>
#include<QIcon>
#include<ctime>

extract::extract(QMainWindow *parent) : QMainWindow(parent)
{
    this->setFixedSize(1920,1080);
    this->setWindowTitle("陵薮市朝");
    this->setWindowIcon(QIcon(":/kgs/timg.jpg"));

    myPushButton *bn1=new myPushButton(":kgs/btn4.png",":kgs/btn2.png");//单抽
    bn1->setParent(this);
    bn1->move(1148,970);

    myPushButton *bn2=new myPushButton(":kgs/btn1.png",":kgs/btn3.png");//十连抽
    bn2->setParent(this);
    bn2->move(1522,970);

    myPushButton *bn3=new myPushButton(":kgs/btn5.png",":kgs/btn6.png");//详情
    bn3->setParent(this);
    bn3->move(258,1000);

    widget * exw =new widget;

    connect(bn3,&myPushButton::clicked,this,[=](){
        exw->str=":/kgs/1.png";
        exw->show();
    });

    srand((int)time(NULL));

    connect(bn1,&myPushButton::clicked,this,[=](){
        exw->str=":/kgs/34/zhongli.png";
        exw->show();
        QTimer::singleShot(1000,this,[=]()
        {
            exw->close();
        });

    });

    connect(bn2,&myPushButton::clicked,this,[=](){
        exw->str=":/kgs/34/zhongli.png";
        exw->show();
        QTimer::singleShot(1000,this,[=]()
        {
            exw->close();
        });
    });
}

void extract::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/kgs/3.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);

}

int extract::extract345()
{
    int num = rand() % 1000;
    if (num >= 0 && num <= 6)
        return 5;
    if (num > 6 && num < 58)
         return 4;
    else return 3;
}
